package com.newenergy.wisehome.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.newenergy.wisehome.R;
import com.newenergy.wisehome.config.AppManager;
import com.newenergy.wisehome.data.bean.DeviceCategory;

import butterknife.BindView;
import butterknife.OnClick;
import me.yokeyword.fragmentation.ISupportFragment;

/**
 * Created by kyx on 2018/10/31.
 */

public class SmartSwitchFragment extends BaseFragment {

    private static String ARG_SMART_SWITCH = "arg_smart_switch";

    protected DeviceCategory mDeviceCategory;
    @BindView(R.id.btn_back)
    Button mBtnBack;
    @BindView(R.id.tv_back)
    TextView mTvBack;
    @BindView(R.id.tv_page)
    TextView mTvPage;
    @BindView(R.id.btn_one_switch)
    Button mBtnOneSwitch;
    @BindView(R.id.btn_two_switch)
    Button mBtnTwoSwitch;
    @BindView(R.id.btn_three_switch)
    Button mBtnThreeSwitch;


    public static ISupportFragment newInstance(DeviceCategory mainItem) {
        Bundle args = new Bundle();
        args.putParcelable(ARG_SMART_SWITCH, mainItem);
        SmartSwitchFragment fragment = new SmartSwitchFragment();
        fragment.setArguments(args);
        return fragment;

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_smart_switch;
    }


    @Override
    public void init(View rootView) {
        mDeviceCategory = getArguments().getParcelable(ARG_SMART_SWITCH);
        mTvPage.setText(mDeviceCategory.getName());

    }




    @OnClick({R.id.btn_back, R.id.tv_back, R.id.btn_one_switch, R.id.btn_two_switch, R.id.btn_three_switch})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_back:

                doBack();
                break;
            case R.id.tv_back:

                doBack();
                break;
            case R.id.btn_one_switch:
                AppManager.getInstance(mainActivity).commandAdvertise("01", mDeviceCategory.getFamilyId(), mDeviceCategory.getGroupId(), "01000000", "000000", mCurrFamily.getSeed(), mCurrFamily.getFeedback(), 1, "720B");


                break;
            case R.id.btn_two_switch:
                AppManager.getInstance(mainActivity).commandAdvertise("01", mDeviceCategory.getFamilyId(), mDeviceCategory.getGroupId(), "02000000", "000000", mCurrFamily.getSeed(), mCurrFamily.getFeedback(), 1, "720B");


                break;
            case R.id.btn_three_switch:
                AppManager.getInstance(mainActivity).commandAdvertise("01", mDeviceCategory.getFamilyId(), mDeviceCategory.getGroupId(), "03000000", "000000", mCurrFamily.getSeed(), mCurrFamily.getFeedback(), 1, "720B");


                break;
        }
    }
}
